// /pages/pay-success/pay-success.js  由于等待银行接口返回时间太长，支付完了直接去列表不走这个页面，暂时保留

var request = require('../../utils/request.js');
var config = require('../../config.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    money: 0,
    pay_status: '',
    submit_id:{
      _id:'',
      pay_status:''
    },
    resData: {
      pay_amount:"",
      transaction_id: "",
      pay_time: "",
      shop_name: "",
      pay_type: ""
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    this.setData({
      money: options.money
    })
    that.data.submit_id._id = options.orderId;
    that.data.submit_id.pay_status = options.pay_status;
    request.get({ 'path': config.payForResults }, that.data.submit_id).then(function (res) {
      var resData = res.data.data
      that.setData({
        'resData.transaction_id': resData.transaction_id,
        'resData.pay_time': resData.pay_time,
        'resData.shop_name': resData.shop_name,
        'resData.pay_type': resData.pay_type,
        'resData.pay_amount': resData.pay_amount
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },
  getInfo(data){
    request.get({'path': config.orderInfo}, data).then(function(res){
      var ratingData = res.data;
      if (ratingData.ret == 0) {
        
      } else {
        wx.showToast({
          icon: 'none',
          title: res.data.msg
        })
        return false;
      }
    }, function(res){
      wx.showToast({
        icon: 'none',
        title: res.data.msg
      })
      return false;
    })
  },
  finishTap(){
    var that = this;
    wx.navigateTo({
      url: '/pages/work-center/work-center?orderId=' + that.data.submit_id._id
    })
  }
})